package com.ruoyi.equipment.service.impl;

import com.ruoyi.equipment.domain.LgOrderLocation;
import com.ruoyi.equipment.domain.LgTemperature;
import com.ruoyi.equipment.domain.LgVehicle;
import com.ruoyi.equipment.mapper.LgTemperatureMapper;
import com.ruoyi.equipment.service.LgTemperatureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: lek
 * @Description: TODO
 * @Date: 2025/3/5 11:27
 * @Version: 1.0
 */
@Service
public class LgTemperatureServiceImpl implements LgTemperatureService {
    @Autowired
    private LgTemperatureMapper lgTemperatureMapper;

    /**
     * @author maisan
     * @description 查询所有设备信息
     * @createTime  2025/3/5 11:46
     * @param lgTemperature
     * @return
     **/
    @Override
    public List<LgTemperature> selectLgTemperatureList(LgTemperature lgTemperature) {
//        QueryWrapper<LgTemperature> queryWrapper = new QueryWrapper<>();
//        queryWrapper.like(lgTemperature.getOrderNumber() != null,"order_number",lgTemperature.getOrderNumber())
//        .like(lgTemperature.getDeviceNumber() != null,"device_number",lgTemperature.getDeviceNumber())
//        .eq(lgTemperature.getCurrentStatus() != null,"current_status",lgTemperature.getCurrentStatus())
//        .between(lgTemperature.getParams().get("beginTime") != null,"create_time",lgTemperature.getParams().get("beginTime"),lgTemperature.getParams().get("endTime"));
//        return lgTemperatureMapper.selectList(queryWrapper);
        return lgTemperatureMapper.selectLgTemperatureList(lgTemperature);
    }

    /**
     * @author maisan
     * @description 根据id查询设备信息
     * @createTime  2025/3/5 11:46
     * @param id
     * @return
     **/
    @Override
    public LgTemperature selectLgTemperatureById(Integer id) {
        return lgTemperatureMapper.selectLgTemperatureById(id);
    }

    /**
     * @author maisan
     * @description 修改设备信息
     * @createTime  2025/3/5 11:46
     * @param lgTemperature
     * @return
     **/
    @Override
    public int updateLgTemperature(LgTemperature lgTemperature) {
        return lgTemperatureMapper.updateById(lgTemperature);
    }

    /**
     * @author maisan
     * @description 新增设备信息
     * @createTime  2025/3/5 11:46
     * @param lgTemperature
     * @return
     **/
    @Override
    public int insertLgTemperature(LgTemperature lgTemperature) {
        return lgTemperatureMapper.insert(lgTemperature);
    }

    /**
     * @author maisan
     * @description 根据id删除设备信息
     * @createTime  2025/3/5 11:46
     * @param id
     * @return
     **/

    public int deleteLgTemperatureById(Integer id){
        return lgTemperatureMapper.deleteById(id);
    }

    /**
     * @author maisan
     * @description 根据ids删除设备信息
     * @createTime  2025/3/5 11:46
     * @param id
     * @return
     **/

    public int deleteLgTemperatureByIds(Integer[] id){
        for (int i = 0; i < id.length; i++){
            LgTemperature lgTemperature = lgTemperatureMapper.selectLgTemperatureById(id[i]);
            lgTemperature.setId(id[i]);
            lgTemperature.setBoundId(0);
            //删除时解车辆
            lgTemperatureMapper.updateById(lgTemperature);
        }
        return lgTemperatureMapper.deleteBatchIds(Arrays.asList(id));
    }

    /**
     * @author maisan
     * @description 查询车辆信息
     * @createTime  2025/3/6 17:15
     * @param
     * @return
     **/
    public LgVehicle selectVehicleById(Integer id){
        return lgTemperatureMapper.selectVehicleById(id);
    }

    /**
     * @author maisan
     * @description 更新车辆信息
     * @createTime  2025/3/6 17:15
     * @param
     * @return
     **/
    public int updateVehicle(LgVehicle lgVehicle){
        return lgTemperatureMapper.updateVehicle(lgVehicle);
    }
    /**
     * @author maisan
     * @description 查询车辆信息
     * @createTime  2025/3/6 19:51
     * @param [com.ruoyi.equipment.domain.LgVehicle]
     * @return java.util.List<com.ruoyi.equipment.domain.LgVehicle>
     **/

    public List<LgVehicle> selectLgVehicleList(LgVehicle lgVehicle){
        return lgTemperatureMapper.selectLgVehicleList(lgVehicle);
    }
    /**
     * @author maisan
     * @description //TODO 已被绑定设备的订单经纬度信息
     * @createTime  2025/3/12 11:17
     * @param
     * @return
     **/
    @Override
    public int insertOrderLocation() {
        return lgTemperatureMapper.insertOrderLocation();
    }

    @Override
    public List<LgTemperature> getTemperatureByOrder(Integer stockOrderNumber) {
        return lgTemperatureMapper.getTemperatureByOrder(stockOrderNumber);
    }

    @Override
    public List<LgTemperature> getTemperatureByOrderGo(Integer stockOrderNumber) {
        return lgTemperatureMapper.getTemperatureByOrderGo(stockOrderNumber);
    }


}
